//
//  ModifyViewController.m
//  Daybook
//
//  Created by liutaifeng on 16/5/26.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "ModifyViewController.h"
#import "AccountBookSQL.h"

@interface ModifyViewController ()
<
 ModifyViewDelegate
>
@property (nonatomic, strong) ModifyView *modifyView;
@property (nonatomic, strong) NSString *name;
@end

@implementation ModifyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createView];
}
- (void)setModel:(AccountBookModel *)model {
    if (_model != model) {
        _model = model;
        _modifyView.model = _model;
    }
}

- (void)createView {
    self.modifyView = [[ModifyView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:_modifyView];
    _modifyView.model = self.model;
    _modifyView.delegate = self;
    self.name = self.model.accountBookName;
}
- (void)back {
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}
- (void)saveModel:(AccountBookModel *)model {
    [[AccountBookSQL shareDataBaseTool] updateModel:model name:self.name];
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
